package xinxin.com.ChainofResponsibilityPatternBasic;

import xinxin.com.ChainofResponsibilityPatternBasic.Handler.Handler;
import xinxin.com.ChainofResponsibilityPatternBasic.Handler.concrete.ConcreteHandler1;
import xinxin.com.ChainofResponsibilityPatternBasic.Handler.concrete.ConcreteHandler2;
import xinxin.com.ChainofResponsibilityPatternBasic.Handler.concrete.ConcreteHandler3;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/4/1 20:07
 */
public class ChainofResponsibilityPatternBasic {
    public static void main(String[] args) {
        Handler handler1 = new ConcreteHandler1();
        Handler handler2 = new ConcreteHandler2();
        Handler handler3 = new ConcreteHandler3();
        handler1.setSuccessor(handler2);
        handler2.setSuccessor(handler3);

        int[] requests = {2, 3, 14, 22, 18, 3, 27, 20, 45};

        for (int request : requests) {
            handler1.HandleRequest(request);
        }
    }
}
